#pragma once
#include <d3d9.h>
#include <d3dx9.h>

class CSprite
{
protected:
	LPDIRECT3DTEXTURE9	m_Image;			//image of the sprite
	LPD3DXSPRITE		m_SpriteHandler;	//sprite handler

	LPCSTR	m_FilePath;

	int mi_Count;		//number of sprite in the image
	int mi_PerRow;		//sprite per row
	
	int mi_Index;		//index of the current sprite
	int mi_Width;		//sprite's width
	int mi_Height;		//sprite's height
	int mi_SpriteLine;	//line of current sprite

	float mf_Scale;		//scale rate of the X axis

	D3DCOLOR	m_TransColor;	//the transparent color to draw the sprite

public:
	CSprite();
	~CSprite();

	//load image, init variables
	//
	void CreateSprite(LPD3DXSPRITE SpriteHandler, LPCSTR FilePath, int iWidth, int iHeight, int iPerRow, int iCount,
			float fScale, D3DCOLOR TransColor);
	
	//method use to load sprite image
	//
	void LoadImage();
	
	//get method
	//
	int GetSpriteLine(void);	//get current line of the sprite
	int GetIndex(void);			//get current sprite's index
	int GetWidth(void);			//get sprite's width
	int GetHeight(void);		//get sprite's height
	int GetCount(void);			//get sprite's count
	int GetPerRow(void);		//get number of the sprite

	//set method
	//
	void SetSpriteLine(int iLine);
	void SetIndex(int iIndex);


	void Next(void);		//set current sprite to the next sprite
	void Reset(void);		//set sprite to the begin

	//render current sprite ay location (X,Y) at the target surface
	void Render(int ix, int iy);
	
	//scaling, rotate, transform the sprite
	void Transform(float, float);			
};
